<!DOCTYPE html>


<html lang="zh-Hans">
  

    <head>
      <meta charset="utf-8" />
       
      <meta name="keywords" content="博客，代码，思考，生活" />
       
      <meta name="description" content="笔记汇总" />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>字符串&amp;Math&amp;Arrays |  Zhang Shuo&#39;s Studio</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/hexo1/favicon.ico" />
       
<link rel="stylesheet" href="/hexo1/dist/main.css">

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css"
      />
      
<link rel="stylesheet" href="/hexo1/css/custom.css">
 
      <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    <link rel="alternate" href="/hexo1/atom.xml" title="Zhang Shuo's Studio" type="application/atom+xml">
</head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-java基础/字符串&amp;Math&amp;Arrays"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  字符串&amp;Math&amp;Arrays
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/hexo1/2019/08/13/java%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2&Math&Arrays/" class="article-date">
  <time datetime="2019-08-13T09:00:00.000Z" itemprop="datePublished">2019-08-13</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/hexo1/categories/java%E5%9F%BA%E7%A1%80/">java基础</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">6 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h3 id="总结："><a href="#总结：" class="headerlink" title="总结："></a><strong>总结：</strong></h3><p>1. 构造字符串的四种方法，如何把char数组和byte数组转为字符串 </p>
<p>2. 忽略大小写比较 Boolean flag = “java”.equalsIgnoreCase(“JAVA”) </p>
<p>3. 字符串转为char字符数组 char[] chr = str1.toCharArray()<br>4.获取索引位置的元素 char ch = “hello”.charAt(4);</p>
<p>5.拼接 String s1 = “Hello”.concat(“Word”); </p>
<p>6. 截取 <code>String str5 = &quot;abcdefghijk&quot;.substring(3,6);</code> // [3,6) </p>
<p><code>String str6 = &quot;abcdefghijk&quot;.substring(3);</code> //从第四个开始后面所有内容 </p>
<p>7. 内容替换 System.out.println(“how do you do?”.replace(“o”, “*”)); </p>
<p>8. 分割 String[] array1 = “aaa,bbb,ccc”.split(“,”); String[] array2 = “aaa.bbb.ccc”.split(“.“); //参数是正则表达式 </p>
<p>9. 查找第一次出现的索引，没有则返回-1 int index = “hello”.indexOf(“ll”); </p>
<p>10. 数组转为字符串 String str = Arrays.toString(array)</p>
<p>11. 字符串转为byte比特数组 byte[] b = “罗成”.getBytes();</p>
<p>12. 数组排序，注意区别集合排序) Arrays.sort(Object[] array, int A, int B) //[A, B) </p>
<p>13. 数组填充 Arrays.fill(Object[] array, int A, int B, Object object) //[A, B) </p>
<p>14. 多维数组转为字符串 Arrays.deepToString(Object[][] arrays)</p>
<p>15. 数组复制，扩展 int[] b = Arrays.copyOf(a, a.length * 2);</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">public static double abs(double num); // 绝对值,有多种重载</span><br><span class="line">public static double ceil(double num); // 向上取整 public </span><br><span class="line">static double floor(double num); // 向下取整 </span><br><span class="line">public static long round(double num); // 四舍五入</span><br></pre></td></tr></table></figure>
<h3 id="字符串"><a href="#字符串" class="headerlink" title="字符串"></a><strong>字符串</strong></h3><p><strong>1. 四种构造方法</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">char[] charArray = &#123;&#x27;a&#x27;, &#x27;b&#x27;, &#x27;c&#x27;&#125;; </span><br><span class="line">String str1 = new String(charArray);</span><br><span class="line">byte[] byteArray = &#123;97, 98, 99&#125;; //ASCII码 </span><br><span class="line">String str2 = new String(byteArray); </span><br><span class="line">String str3 = &quot;abc&quot;; </span><br><span class="line">String str4 = new String(&quot;abc&quot;); </span><br></pre></td></tr></table></figure>
<ul>
<li>若上述四个字符串用 == 比较皆为false， 因为比较的是四个栈的内容，即四个”abc”的地址，而四个”abc”的地址皆不同 双引号直接写的字符串在常量池中，new的不在池中</li>
</ul>
<p><code>String strA = &quot;Hello&quot;; strA = &quot;hello&quot;;</code> </p>
<ul>
<li>上面的写法，字符串内容仍然是没有改变的 strA中保存的地址值一开始是”Hello”的地址值,后来改为”hello”的地址值 下述的”Hello”没有改变，只是新建了个”hello”并剥夺了索引</li>
</ul>
<p> <strong>2. 比较</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(null.equals(str1)); //报错,空指针异常</span><br><span class="line">System.out.println(str1.equals(null)); //输出false</span><br></pre></td></tr></table></figure>
<p>忽略大小写比较 <strong>equalsIgnoreCase</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(&quot;java&quot;.equalsIgnoreCase(&quot;JAVA&quot;)); //true</span><br></pre></td></tr></table></figure>
<p><strong>3. 字符串不能直接当数组使用</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">char c1 = &quot;abcde&quot;.[0]; //错误</span><br></pre></td></tr></table></figure>
<ul>
<li>应该先转为字符数组 <strong>toCharArray</strong><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">char[] c1 = str1.toCharArray(); </span><br><span class="line">System.out.println(c1[0]);</span><br></pre></td></tr></table></figure></li>
</ul>
<p><strong>4. 获取索引位置的元素</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">char ch = &quot;hello&quot;.charAt(4); // &#x27;o&#x27;</span><br></pre></td></tr></table></figure>
<p><strong>5. 拼接</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">String s1 = &quot;Hello&quot;.concat(&quot;Word&quot;);</span><br></pre></td></tr></table></figure>
<p><strong>6. 截取</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">public String substring(int begin, int end); </span><br><span class="line"></span><br><span class="line">String str5 = &quot;abcdefghijk&quot;.substring(3,6);  //[3,6) </span><br><span class="line"></span><br><span class="line">String str6 = &quot;abcdefghijk&quot;.substring(3); //从第四个开始后面所有内容</span><br></pre></td></tr></table></figure>
<p><strong>7. 内容替换</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">System.out.println(&quot;how do you do?&quot;.replace(&quot;o&quot;, &quot;*&quot;));</span><br></pre></td></tr></table></figure>
<p><strong>8. 分割，并返回数组</strong></p>
<p>split方法的参数是一个&quot;正则表达式&quot; * </p>
<p>如果要对&quot;.&quot;切分，比如改为&quot;\\.&quot; </p>
<p><code>String[] array1 = &quot;aaa,bbb,ccc&quot;.split(&quot;,&quot;); </code></p>
<p><code>String[] array2 = &quot;aaa.bbb.ccc&quot;.split(&quot;.&quot;); // 切分失败</code></p>
<p><strong>9. 查找第一次出现的位置</strong></p>
<p>查找字符串在原字符串中第一次出现的位置索引，若没有则返回-1 int index = &quot;hello&quot;.indexOf(&quot;ll&quot;); int index = &quot;hello&quot;.indexOf(&quot;o&quot;);</p>
<p><strong>10. 字符串转为数组</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">char[] array = &quot;aqwqdqwdqd&quot;.toCharArray();</span><br></pre></td></tr></table></figure>

<p><strong>11. 数组转为字符串</strong></p>
<p><code>String str = Arrays.toString(array)</code></p>
<p><strong>12. 如何随机生成字母</strong></p>
<p>先随机生成97-122之间的int整数，再转化为char类型，再拼接</p>
<p><code>int intVal = (int)(Math.random()* 26 + 97); </code></p>
<p>将intValue强制转换为char类型后连接到result后面 result = result + (char)intVal;</p>
<p><strong>1、将字符串转换成byte数组</strong></p>
<p><code>byte[] b = &quot;罗成&quot;.getBytes();</code></p>
<p> </p>
<p><strong>2、将byte数组转换成字符串</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">byte[] b=&#123;(byte)0xB8,(byte)0xDF,(byte)0xCB,(byte)0xD9&#125;;</span><br><span class="line"></span><br><span class="line">String str= new String (b);</span><br></pre></td></tr></table></figure>
<hr>
<h3 id="Arrays类"><a href="#Arrays类" class="headerlink" title="Arrays类"></a><strong>Arrays类</strong></h3><p>Arrays类位于<strong>java.util</strong>包中,主要包含了<strong>操纵数组</strong>的各种方法</p>
<p><strong>一、Arrays.sort(Object[] array, int from, int to)</strong></p>
<p>功能：对数组元素指定范围进行 <strong>排序</strong>（排序范围是从元素下标为from,到下标为to-1的元素进行排序）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">int[] nums = &#123;2,5,0,4,1,-10&#125;; //对前四位元素进行排序 </span><br><span class="line"></span><br><span class="line">Arrays.sort(nums, 0, 4); </span><br><span class="line"></span><br><span class="line">for(int i :nums) System.out.print(i+&quot; &quot;); 之前:2 5 0 4 1 -10 结果:0 2 4 5 1 -10</span><br></pre></td></tr></table></figure>
<p><strong>二、Arrays.fill(Object[] array, int from, int to, Object object)</strong></p>
<p>功能：对数组的部分元素 <strong>填充</strong> 一个值,从起始位置到结束位置，取头不取尾，不写from与to默认填充全部内容</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">int[] nums = &#123;2,5,0,4,1,-10&#125;; //对数组元素下标2到4的元素赋值为3 </span><br><span class="line"></span><br><span class="line">Arrays.fill(nums,2,5,3); </span><br><span class="line"></span><br><span class="line">for(int i :nums) System.out.print(i+&quot; &quot;); 之前:2 5 0 4 1 -10 结果:2 5 3 3 3 -10</span><br></pre></td></tr></table></figure>
<p><strong>三、 Arrays.toString(Object[] array)</strong></p>
<p>功能：<strong>返回</strong>数组的字符串形式</p>
<p>示例</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">int[] nums = &#123;2,5,0,4,1,-10&#125;;</span><br><span class="line">System.out.println(Arrays.toString(nums)); </span><br><span class="line">// 不要写nums.toString() 结果:[2, 5, 0, 4, 1, -10]</span><br></pre></td></tr></table></figure>
<p><strong>四、 Arrays.deepToString(Object[][] arrays)</strong></p>
<p>功能：返回<strong>多维</strong>数组的<strong>字符串</strong>形式</p>
<p>示例</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">int[][] nums = &#123;&#123;1,2&#125;,&#123;3,4&#125;&#125;;</span><br><span class="line">System.out.println(Arrays.deepToString(nums)); 结果:[[1, 2], [3, 4]]</span><br></pre></td></tr></table></figure>
<p><strong>五、数组拷贝</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">int[] b = Arrays.copyOf(a, a.length);</span><br></pre></td></tr></table></figure>
<p><strong>扩展数组本身长度</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">a = Arrays.copyOf(a, 2*a.length)</span><br></pre></td></tr></table></figure>
<p><strong>Math类</strong></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">public static double abs(double num); // 绝对值,有多种重载</span><br><span class="line">public static double ceil(double num); // 向上取整 </span><br><span class="line">public static double floor(double num); // 向下取整 </span><br><span class="line">public static long round(double num); // 四舍五入</span><br><span class="line">Double num1 = Math.abs(-2.301); </span><br><span class="line">int num2 = Math.round(Math.PI);</span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          Donate
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://gitee.com/zhang-shuo-fr/hexo1.git/2019/08/13/java%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2&Math&Arrays/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo1/tags/%E5%AD%97%E7%AC%A6%E4%B8%B2-Math-Arrays/" rel="tag">字符串&Math&Arrays</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/hexo1/2019/08/13/java%E5%9F%BA%E7%A1%80/StringBuffer&StringBuilder/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            StringBuffer&amp;StringBuilder
          
        </div>
      </a>
    
    
      <a href="/hexo1/2019/08/13/java%E5%9F%BA%E7%A1%80/static/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">static#说明：文章标题</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "",
    app_key: "",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2020-2021
        <i class="ri-heart-fill heart_icon"></i> Zhang Shuo
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src=''></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/hexo1/"><img src="/hexo1/images/ayer-side.svg" alt="Zhang Shuo&#39;s Studio"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://shenyu-vip.lofter.com">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo1/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/hexo1/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/hexo1/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/hexo1/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/hexo1/js/jquery-3.6.0.min.js"></script>
 
<script src="/hexo1/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/hexo1/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/hexo1/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/hexo1/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/hexo1/css/clipboard.css">
 <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=22707008&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
    

  </div>
</body>

</html>